
*************************************************************************
** 							GENDER AND WEALTH						   **
**					Doron Shiffer-Sebba and Julia Behrman 			   **
**						Last updated: 10/19/2020, DSS				   **
*************************************************************************


***************************************************************************
*** SETUP *****************************************************************
***************************************************************************	 

version 14.2
clear
capture log close
set more off

global path    "/localpath"   /* Adjust to user project folder path */

log using ""$path/output/1", replace

***************************************************************************
*** CONTENTS **************************************************************
***************************************************************************

/*

- Import Data
- Estimate Maximum and Minimum Years of Birth for Owner/s
	- Transform year of purchase date to year
	- Calculate maximum and minimum age based on purchase year
	- Calculate maximum and minimum age based on data record year
	
*/

***************************************************************************
*** CLEANING **************************************************************
***************************************************************************

// Import Data
import delimited using "$path/data/data.csv", clear


// Estimate Maximum and Minimum Years of Birth for Owner/s
gen double detia = date(yearofpurchase,"YMDhms")	// Transform year of purchase date to year
gen year = yofd(detia)
drop detia
gen minbirth = 1925 if (year < 1951 | year == .)	// Calculate maximum and minimum age based on purchase year
gen maxbirth = 1998 if (year < 1951 | year == .)
replace minbirth = year - 90 if minbirth == .
replace maxbirth = year - 19 if maxbirth == .
replace minbirth = 1925 if minbirth < 1925			// Calculate maximum and minimum age based on data record year
replace maxbirth = 1998 if maxbirth > 1998
gen agerange = maxbirth - minbirth

export delimited using "$path/data/clean1", replace

clear
capture log close
exit


***************************************************************************
***************************************************************************
***************************************************************************

